<?php

/**
 * Zone form base class.
 *
 * @method Zone getObject() Returns the current form's model object
 *
 * @package    raidpoints
 * @subpackage form
 * @author     David Driscoll
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 24171 2009-11-19 16:37:50Z Kris.Wallsmith $
 */
abstract class BaseZoneForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'      => new sfWidgetFormInputHidden(),
      'sort'    => new sfWidgetFormInputText(),
      'short'   => new sfWidgetFormInputText(),
      'name'    => new sfWidgetFormInputText(),
      'shown'   => new sfWidgetFormInputCheckbox(),
      'clear'   => new sfWidgetFormInputCheckbox(),
      'tracked' => new sfWidgetFormInputCheckbox(),
    ));

    $this->setValidators(array(
      'id'      => new sfValidatorDoctrineChoice(array('model' => $this->getModelName(), 'column' => 'id', 'required' => false)),
      'sort'    => new sfValidatorInteger(),
      'short'   => new sfValidatorString(array('max_length' => 7)),
      'name'    => new sfValidatorString(array('max_length' => 100)),
      'shown'   => new sfValidatorBoolean(array('required' => false)),
      'clear'   => new sfValidatorBoolean(array('required' => false)),
      'tracked' => new sfValidatorBoolean(array('required' => false)),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorAnd(array(
        new sfValidatorDoctrineUnique(array('model' => 'Zone', 'column' => array('short'))),
        new sfValidatorDoctrineUnique(array('model' => 'Zone', 'column' => array('name'))),
      ))
    );

    $this->widgetSchema->setNameFormat('zone[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Zone';
  }

}
